.row.wrapper.border-bottom.white-bg.page-heading
  .col-lg-12
    h2 Cron&#x4EFB;&#x52A1;
    |         
    ol.breadcrumb
      li
        a &#x4EFB;&#x52A1;&#x961F;&#x5217;&#x7BA1;&#x7406;
      |             
      li.active
        b Cron&#x4EFB;&#x52A1;
.wrapper.wrapper-content.animated.fadeInRight
  .row
    .col-lg-12
      .ibox
        .ibox-title
          h3
            span.text-navy Cron&#x4EFB;&#x52A1;
        |                 
        .ibox-content
          form#form.form-horizontal(method='post', onsubmit='return false')
            .form-group
              label.col-sm-2.control-label(style='width:10%') &#x4EFB;&#x52A1;ID
              |                             
              .col-sm-3
                input.form-control(type='text', name='taskId', placeholder='请输入任务ID(TaskId)')
              |                             
              label.col-sm-2.control-label(style='width:10%') &#x63D0;&#x4EA4;&#x8282;&#x70B9;&#x7EC4;
              |                             
              .col-sm-3
                select.form-control(name='submitNodeGroup')
                  option(value='') -- &#x4E0D;&#x9650; --
                  |                                     #foreach($nodeGroup in $jobClientNodeGroups)
                  |                                         
                  option(value='$nodeGroup.name') $nodeGroup.name
                  |                                     #end
            |                         
            .form-group
              label.col-sm-2.control-label(style='width:10%') &#x6267;&#x884C;&#x8282;&#x70B9;&#x7EC4;
              |                             
              .col-sm-3
                select.form-control(name='taskTrackerNodeGroup')
                  option(value='') -- &#x4E0D;&#x9650; --
                  |                                     #foreach($nodeGroup in $taskTrackerNodeGroups)
                  |                                         
                  option(value='$nodeGroup.name') $nodeGroup.name
                  |                                     #end
              |                             
              label.col-sm-2.control-label(style='width:10%') &#x53CD;&#x9988;&#x5BA2;&#x6237;&#x7AEF;
              |                             
              .col-sm-2
                select.form-control(name='needFeedback')
                  option(value='') -- &#x4E0D;&#x9650; --
                  |                                     
                  option(value='true') &#x9700;&#x8981;
                  |                                     
                  option(value='false') &#x4E0D;&#x9700;&#x8981;
              |                             
              .col-sm-1(style='width:70px;')
                button#searchBtn.btn.btn-primary(type='button')
                  | &#x641C;&#x7D22;
              |                             
              .col-sm-1
                button#resetBtn.btn.btn-warning(type='reset')
                  | &#x91CD;&#x7F6E;
            |                         
            .hr-line-dashed
  |     
  .row
    .col-lg-12
      .ibox
        #ltstableContainer.ibox-content
  |     &grave;
#job-edit-modal.modal.inmodal(role='dialog', aria-hidden='true', style='display: none;')
  .modal-dialog(style='width: 600px;')
    .modal-content.animated.rubberBand
      .modal-header
        button.close(type='button', data-dismiss='modal')
          span(aria-hidden='true') &times;
          span.sr-only &#x5173;&#x95ED;
        |                 
        h2.modal-title &#x7F16;&#x8F91;&#x4EFB;&#x52A1;&#x4FE1;&#x606F;
      |             
      .modal-body
        .row
          form#editForm.form-horizontal(method='post', onsubmit='return false')
            input.form-control(type='hidden', name='jobId')
            |                         
            input.form-control(type='hidden', name='taskId')
            |                         
            .form-group
              label.col-sm-2.control-label.w_120 Cron&#x8868;&#x8FBE;&#x5F0F;
              |                             
              .col-sm-3
                input.form-control.w_250(type='text', name='cronExpression', placeholder='请输入CronExpression')
            |                         
            .form-group
              label.col-sm-2.control-label.w_120 &#x53CD;&#x9988;&#x5BA2;&#x6237;&#x7AEF;
              |                             
              .col-sm-3.w_250
                select.form-control(name='needFeedback')
                  option(value='true') &#x9700;&#x8981;
                  |                                     
                  option(value='false', selected='') &#x4E0D;&#x9700;&#x8981;
            |                         
            .form-group
              label.col-sm-2.control-label.w_120 &#x4F18;&#x5148;&#x7EA7;
              |                             
              .col-sm-3.w_250
                input.form-control(type='text', name='priority', value='100', placeholder='必须为数字，数值越小，优先级越大【必填】')
            |                         
            .form-group
              label.col-sm-2.control-label.w_120 &#x63D0;&#x4EA4;&#x8282;&#x70B9;&#x7EC4;
              |                             
              .col-sm-3.w_250
                select.form-control(name='submitNodeGroup')
                  option(value='') -- &#x8BF7;&#x9009;&#x62E9;&#x63D0;&#x4EA4;&#x8282;&#x70B9;&#x7EC4; --
                  |                                     #foreach($nodeGroup in $jobClientNodeGroups)
                  |                                         
                  option(value='$nodeGroup.name') $nodeGroup.name
                  |                                     #end
            |                         
            .form-group
              label.col-sm-2.control-label.w_120 &#x6267;&#x884C;&#x8282;&#x70B9;&#x7EC4;
              |                             
              .col-sm-3.w_250
                select.form-control(name='taskTrackerNodeGroup')
                  option(value='') -- &#x8BF7;&#x9009;&#x62E9;&#x6267;&#x884C;&#x8282;&#x70B9;&#x7EC4; --
                  |                                     #foreach($nodeGroup in $taskTrackerNodeGroups)
                  |                                         
                  option(value='$nodeGroup.name') $nodeGroup.name
                  |                                     #end
            |                         
            .form-group
              label.col-sm-2.control-label.w_120 &#x7528;&#x6237;&#x53C2;&#x6570;
              |                             
              .col-sm-4.w_340
                textarea.form-control(type='text', name='extParams', placeholder='请输入用户参数 JSON格式【非必填】')
            |                         
            .hr-line-dashed
            |                         
            .form-group
              .col-sm-1.col-sm-offset-3(style='width:70px;')
                button#editBtn.btn.btn-primary(type='button')
                  | &#x4FEE;&#x6539;
              |                             
              .col-sm-1
                button.btn.btn-warning(data-dismiss='modal') &#x5173;&#x95ED;
script#ltstable(type='text/html').
  <table class="table table-stripped toggle-arrow-tiny footable" data-page-size="10">
  <thead>
  <tr>
  <th data-toggle="true">任务ID</th>
  <th data-hide="all">提交节点组</th>
  <th>执行节点组</th>
  <th>Cron表达式</th>
  <th data-hide="all">优先级</th>
  <th>反馈客户端</th>
  <th data-hide="all">用户参数</th>
  <th data-hide="phone,tablet">创建时间</th>
  <th data-hide="all">修改时间</th>
  <th>操作</th>
  </tr>
  </thead>
  <tbody>
  {{each rows as row index}}
  <tr>
  <td>{{row.taskId}}</td>
  <td>{{row.submitNodeGroup}}</td>
  <td>{{row.taskTrackerNodeGroup}}</td>
  <td>{{row.cronExpression}}</td>
  <td>{{row.priority}}</td>
  <td>{{row.needFeedback | format:'needFeedbackLabel',row}}</td>
  <td>{{row.extParams | format:'stringifyJSON'}}</td>
  <td>{{row.gmtCreated | dateFormat:'yyyy-MM-dd HH:mm:ss'}}</td>
  <td>{{row.gmtModified | dateFormat:'yyyy-MM-dd HH:mm:ss'}}</td>
  <td>{{row.opt | format:'optFormat',row}}</td>
  </tr>
  {{/each}}
  {{if results == 0}}
  <tr>
  <td colspan="15">暂无数据</td>
  </tr>
  {{/if}}
  </tbody>
  <tfoot>
  <tr>
  <td colspan="9">
  <span>共{{results}}条记录，每页展示{{pageSize}}条</span>
  <ul class="pagination-sm pull-right"></ul>
  </td>
  </tr>
  </tfoot>
  </table>
script.
  $(document).ready(function () {
  LTS.colFormatter.optFormat = function (v, row) {
  var logUrl = "job-logger.htm?taskId=" + row['taskId'] + "&taskTrackerNodeGroup=" + row['taskTrackerNodeGroup'];
  return '<a target="_blank" href="' + logUrl + '"><span class="label label-info"><i class="fa fa-file-code-o"></i> 日志</span></a>&nbsp;' +
  '<a href="javascript:;" class="job-edit-btn"><span class="label label-success"><i class="fa fa-edit"></i> 编辑</span><span class="hidden lts-data">' + JSON.stringify(row) + '</span></a>&nbsp;' +
  '<a href="javascript:;" class="job-del-btn" jobId="' + row['jobId'] + '" taskTrackerNodeGroup="' + row['taskTrackerNodeGroup'] + '"><span class="label label-primary" style="background-color: #DD6B55;"><i class="fa fa-trash-o"></i> 删除</span></a>';
  }
  $(document).on("click", ".job-del-btn", function () {
  var that = $(this);
  var jobId = that.attr("jobId");
  var taskTrackerNodeGroup = that.attr("taskTrackerNodeGroup");
  swal({
  title: "确认要删除该任务吗？",
  text: "在等待执行中的该条任务也将会被删除，请谨慎操作 !",
  type: "warning",
  showCancelButton: true,
  confirmButtonColor: "#DD6B55",
  confirmButtonText: "确认删除",
  closeOnConfirm: false
  }, function (isConfirm) {
  if(isConfirm){
  $.ajax({
  url: 'api/job-queue/cron-job-delete',
  type: 'POST',
  dataType: 'json',
  data: {jobId: jobId, taskTrackerNodeGroup: taskTrackerNodeGroup},
  success: function (json) {
  if (json && json.success) {
  swal("删除成功!", "恭喜你", "success");
  that.parents("tr").remove();
  } else {
  json ? swal(json['msg']) : {};
  }
  }
  });
  }
  });
  });
  $(document).on("click", ".job-edit-btn", function () {
  var jobText = $(this).children("span.lts-data").text();
  var job = JSON.parse(jobText);
  $.each($('#editForm').parent().find(".form-control"), function () {
  var name = $(this).attr("name");
  var value = job[name];
  if (name == 'extParams') {
  if (value == null) {
  value = ''
  } else {
  value = JSON.stringify(value);
  }
  } else {
  value = value + '';
  }
  if($(this)[0].tagName.toUpperCase() == 'SELECT'){
  $(this).selectpicker('val', value);
  }else{
  $(this).val(value);
  }
  });
  $("#job-edit-modal").modal("show");
  });
  $(document).on("click", "#editBtn", function () {
  var params = {};
  $.each($('#editForm').parent().find(".form-control"), function () {
  var name = $(this).attr("name");
  var value = $(this).val();
  params[name] = value;
  });
  var cronExpression = params['cronExpression'];
  if (!cronExpression) {
  sweetAlert("请输入Cron表达式", "", "error");
  return;
  }
  var priority = params['priority'];
  if (!priority) {
  sweetAlert("请输入优先级", "必须为数字，数值越小，优先级越大【必填】", "error");
  return;
  }
  if (!LTS.ReExp.number.test(priority)) {
  sweetAlert("优先级格式错误", "必须为数字，数值越小，优先级越大【必填】", "error");
  return;
  }
  if (!params['submitNodeGroup']) {
  sweetAlert("请选择提交节点组", "如果列表中没有，请在节点组管理中添加，并启动改节点。", "error");
  return;
  }
  if (!params['taskTrackerNodeGroup']) {
  sweetAlert("请选择执行节点组", "如果列表中没有，请在节点组管理中添加，并启动改节点。", "error");
  return;
  }
  var extParams = params['extParams'];
  if (extParams) {
  try {
  JSON.parse(extParams)
  } catch (e) {
  sweetAlert("用户参数格式错误", "必须为JSON格式", "error");
  return;
  }
  }
  // 请求修改数据
  $.ajax({
  url: 'api/job-queue/cron-job-update',
  type: 'POST',
  dataType: 'json',
  data: params,
  success: function (json) {
  if (json && json.success) {
  swal("修改成功!", "恭喜你", "success");
  $("#form")[0].reset();
  $("#form").find('select').selectpicker('render');
  $("input[name='taskId']").val(params['taskId']);
  $("#job-edit-modal").modal("hide");
  $("#searchBtn").trigger("click");
  } else {
  json ? swal(json['msg']) : {};
  }
  }
  });
  });
  var ltsTable = $("#ltstableContainer").ltsTable({
  url: 'api/job-queue/cron-job-get',
  templateId: 'ltstable'
  });
  $(document).on("click", "#searchBtn", function () {
  var params = {};
  $.each($('#form').parent().find(".form-control"), function () {
  var name = $(this).attr("name");
  var value = $(this).val();
  params[name] = value;
  });
  ltsTable.post(params, 1);
  });
  $("#searchBtn").trigger("click");
  });
